package fr.upmc.i3s.fuglmeyeranalyser;

import java.io.Console;

import fr.upmc.i3s.fuglmeyeranalyser.models.ExponentialModel;
import fr.upmc.i3s.fuglmeyeranalyser.models.LinearModel;
import fr.upmc.i3s.fuglmeyeranalyser.models.Model;
import fr.upmc.i3s.fuglmeyeranalyser.models.ModelEnum;
import fr.upmc.i3s.fuglmeyeranalyser.models.solutions.SolutionList;
import fr.upmc.i3s.fuglmeyeranalyser.patients.PatientList;
import fr.upmc.i3s.fuglmeyeranalyser.tools.xls.XLSDataFileContent;

public class Processor {
	
	public static final String OUT_FILENAME = "result.xls";
	
	public static Console console;
	
	public static SolutionList compute(ModelEnum model, ModelEnum optim, XLSDataFileContent fileContent) {
		
		//Get patient list from file content
		PatientList patientList = fileContent.getPatientList();
		System.out.println(patientList.toUserString());
		
		Model computeModel = null;
		SolutionList solutions = null;
		
		switch(model) {
		
			case EXPONENTIEL:
				switch(optim) {
				case MCO:
					// Solve MCO for exponential method
					System.out.println("Solve MCO for exponential method\n");
					computeModel = new ExponentialModel();
					solutions = computeModel.solveMCOSystemForPatientList(patientList);
					break;
				case MCP:
					// Solve MCP for exponential method
					System.out.println("Solve MCP for exponential method\n");
					computeModel = new ExponentialModel();
					solutions = computeModel.solveMCPSystemForPatientList(patientList);
					break;
				case MCPK:
					// Solve MCP-k for exponential method
					System.out.println("Solve MCP/k for exponential method\n");
					computeModel = new ExponentialModel();
					solutions = computeModel.solveMCPkSystemForPatientList(patientList);
					break;
				default:
					break;
				}
				break;
				
			case LINEAR:
				switch(optim) {
				case MCO:
					// Solve MCO for linear method
					System.out.println("Solve MCO for linear method\n");
					computeModel = new LinearModel();
					solutions = computeModel.solveMCOSystemForPatientList(patientList);
					break;
				case MCP:
					// Solve MCP for linear method
					System.out.println("Solve MCP for linear method\n");
					computeModel = new LinearModel();
					solutions = computeModel.solveMCPSystemForPatientList(patientList);
					break;
				case MCPK:
					// Solve MCP-k for linear method
					System.out.println("Solve MCP/k for linear method\n");
					computeModel = new LinearModel();
					solutions = computeModel.solveMCPkSystemForPatientList(patientList);
					break;
				default:
					break;
			}
			break;
				
			default:
				break;
		}
		
		//Print solution
		if(solutions != null) {
			System.out.println(solutions.toUserString());
			return solutions;
		
		} else {
			System.out.println("No solution list");
					
		}
		
		return null;
	}

}
